<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>

<div id="app">
    <cpn v-bind:cmovies="movies" :cmessage="message"></cpn>
    <!-- <cpn cmovies="movies" cmessage="message"></cpn> -->
</div>

<template id="cpn">
    <div>
        <ul>
            <li v-for="item in cmovies">{{item}}</li>
        </ul>
        <h2>{{cmessage}}</h2>
    </div>
</template>

<script src="../js/vue.js"></script>
<script>
    // 父传子：props
    const cpn = {
        template: '#cpn',
        // props: ['cmovies', 'cmessage'],
        props: {
            // 1.类型限制
            // cmovie: Array,
            // cmessage: String

            //2.提供一些默认值，以及必传值
            cmessage: {
                type: String,
                default: 'aaaaa',//默认值
                required: true //必传属性
            },
            //类型是对象或者数组时，默认值必须是一个函数
            cmovies: {
                type: Array,
                default() {
                    return []
                }
            }
        },
        data() {
            return {

            }
        },
        methods: {

        }
    }

    const app = new Vue({
        el: '#app',
        data: {
            message: '你好啊',
            movies: ['海王', '海贼王', '海尔兄弟']
        },
        components: {
            cpn
        }
    })
</script>

</body>
</html>